﻿using System;
using System.Collections.Generic;

namespace SapaFinance.Domain.Model
{
    public class Agent : AbstractEntity
    {
        protected Agent()
        {
            //Corporations = new List<Corporation>();
        }

        public  Agent(string name) : this()
        {
            Name = name;
            IsSelfAgent = false;
        }

        public virtual string Name { get; set; }
        //public virtual ICollection<Corporation> Corporations { get; private set; }
        public virtual bool IsSelfAgent { get; set; }

        //public void AddLegalEntity(Corporation corporation)
        //{
        //    corporation.SetAgent(this);
        //    Corporations.Add(corporation);
        //}

        //public void Delete(Corporation corporation, User user)
        //{
        //    corporation.ClearCompany();
        //    corporation.Delete(user);
        //    Corporations.Remove(corporation);
        //}

        public override bool Equals(object obj)
        {
            var compare = (Agent) obj;
            if (ReferenceEquals(null, compare)) return false;
            if (UID != Guid.Empty) return base.Equals(compare);
            return Name.Equals(compare.Name);
        }

    }
}